package com.zzzyh.forumsystemclient.services.impl;

import com.zzzyh.forumsystemclient.dao.User_ArticleMapper;
import com.zzzyh.forumsystemclient.model.User_Article;
import com.zzzyh.forumsystemclient.services.IUserArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 郑雨杭
 * @create 2025/6/3 - 16:24
 */
@Service
public class UserArticleServiceImpl implements IUserArticleService {

    @Autowired
    private User_ArticleMapper user_articleMapper;
    @Override
    public Integer getUserArticleRelationship(Long userId, Long articleId) {
        User_Article userArticle = user_articleMapper.getUserArticle(userId, articleId);
        if(userArticle==null)
            return 5;
        Integer relationship = userArticle.getRelationship();
        return  relationship==null?5:relationship;
    }

    @Override
    public void updateUserArticleRelationship(User_Article user_article) {
        user_articleMapper.updateByPrimaryKeySelective(user_article);
        return;
    }

    @Override
    public User_Article getUserArticle(Long userId, Long articleId) {
        return user_articleMapper.getUserArticle(userId, articleId);
    }

    @Override
    public void insetUserArticle(User_Article userArticle) {
        user_articleMapper.insertSelective(userArticle);
    }

}
